//
// Created by 215609 on 2024/8/7.
//

#ifndef TSAVPLAYER_BASEPLAYER_H
#define TSAVPLAYER_BASEPLAYER_H

#include <jni.h>

extern "C"{
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
#include "libavutil/imgutils.h"
}

class BasePlayer {
public:

    BasePlayer();
    virtual ~BasePlayer();
    virtual void UnInit() = 0;
    virtual JNIEnv *GetJNIEnv(bool *isAttach) = 0;
    AVFormatContext  *avFormatContext;
    virtual JavaVM *GetJavaVM() = 0;
    virtual void init(JNIEnv *jniEnv, jobject obj,char *url,
                      int renderType, jobject surface)=0;
    virtual void Play()=0;

    virtual jobject GetJavaObj()=0;

    virtual void Stop()=0;


private:

    int InitFFDecoder();
    void UnInitDecoder();

    void StartDecodingThread();

    void DecodingLoop();
};


#endif //TSAVPLAYER_BASEPLAYER_H
